<?php
require "../controller/ctrl-main.php";
?>

<!DOCTYPEhtml>
<html>
	<head>
		<title>
			Candy Shop
		</title>
		<link href="../style/style.css" rel="stylesheet" type="text/css" />
		<meta http-equiv="content-type" content="text/html"; charset="utf-8">
	</head>

	<body>
		<div  id="container">


<!-- 

Left menu side   

-->

			<div class="left">
				<div class="nav">
					<a href="../index.php">Категории</a>
					<ul>
						<a href="?offset=0&cat=1">
							<li>Книги</li>
						</a>
						<a href="?offset=0&cat=2">
							<li>Переодика</li>
						</a>
						<a href="?offset=0&cat=3">
							<li>Фото</li>
						</a>
					</ul>
					<a href="bin.php?offset=0&cat=bin">Корзина (<?php echo $quant; ?>)</a>
				</div>
			</div>

<!-- Middle - content part -->

			<div class="mid">
				<div class="filters">
					<form action="?cat=<?php echo $cat; ?>" name="filter-form" method="POST">
						<select name="sort" onchange="this.form.submit();">
							<?php echo $i; ?>
						</select>
					</form>
				</div>
				<div class="products">
					<?php if ($data !==NULL){
					foreach ($data as $ent){ ?>
						<div class="item">
							<a href="?id=<?php echo $ent['id']; ?>&offset=<?php echo $get_off; ?>&cat=<?php echo $cat; ?>&sort=<?php echo $sort; ?>"> 
								<img src="../img/product/<?php echo $ent['img']; ?>" width="72" height="101"/>
							</a>
							<a class="title" href="?id=<?php echo $ent['id']; ?>&offset=<?php echo $get_off; ?>&cat=<?php echo $cat; ?>&sort=<?php echo $sort; ?>">
								<?php echo $ent['title']; ?>
							</a>
							<p><b><?= $ent['price']; ?></b></p>
							<a href="?cat=<?php echo $cat; ?>&
								<?php if (isset($get_id)){ ?>
									id=<?php echo $ent['id'].'&'; ?>
								<?php } ?>
								offset=<?php echo $get_off; ?>&buy=1&buyid=<?php echo $ent['id']; ?>
								&sort=<?php echo $sort ?>">
								<img src="../img/bin/shop-cart-down 32.png" width="32" height="32" />
							</a>
						</div>
					<?php ;} } ?>
				</div>
			</div>

<!-- Right Side  -->

			<div class="right">
				<div class="product-info">
					<?php if (isset($get_id)){ ?>
						<img src="../img/product/<?php echo $all['img']; ?>" width="72" height="101"/>
						<div class="info">
							<p><b>Название: </b><br/><?php echo $all['title']; ?></p>
							<p><b>ISBN: </b><br/><?php echo $all['isbn-sn']; ?></p>
							<p><b>Автор: </b><br/><?php echo $all['author']; ?></p>
							<p><b>Издательство: </b><br/><?php echo $all['publisher']; ?></p>
							<p><b>Краткое описание: </b><br/><?php echo $all['short_descr']; ?></p>
							<p><b>Содержание: </b><br/><?php echo $all['content']; ?></p>
							<p><b>Дата выпуска: </b><br/><?php echo $all['issue_date']; ?></p>
							<p><b>Цена: </b><br/><?php echo $all['price']; ?></p>
							<a href="?cat=<?php echo $cat; ?>&offset=<?php echo $get_off; ?>&id=<?php echo $all['id']; ?>&buy=1&buyid=<?php echo $all['id']; ?>&sort=<?php echo $sort ?>">
								<img src="../img/bin/shop-cart-down 48.png" width="48" height="48" />
							</a>
						</div>
						<?php } ?>
				</div>
			</div>
			
<!-- Footer Side  -->

			<div class="footer">
					<?php
					if($numpages > 1){ ?>
					<div id="nav">
					<!--    //create navigator    -->
					<?php $nav = new Nav($pagename, $totalcount, PERPAGE, $totaloffset, $sort, $cat);
					echo $nav->getNavigator(); ?>
					</div>
				<?php } ?>
			</div>
		</div>
	</body>
</html>